package com.jade.gateway.facade.impl;

import com.jade.gateway.facade.GatewayFacade;
import com.jade.gateway.service.impl.DynamicRouteServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Arnold
 * @version V2.0
 * @className GatewayFacadeImpl
 * @description 网关模块Facade实现
 * @date 2022/01/25 09:20
 **/
@Service("gatewayFacade")
public class GatewayFacadeImpl implements GatewayFacade {
    @Autowired
    DynamicRouteServiceImpl dynamicRouteService;

    @Override
    public Boolean addRoute(List<RouteDefinition> routerDefinitions) {
        routerDefinitions.forEach(routeDefinition -> dynamicRouteService.addRoute(routeDefinition));
        return true;
    }

    @Override
    public Boolean deleteRoute(String id) {
        return dynamicRouteService.deleteRoute(id);
    }

    @Override
    public Boolean updateRoute(RouteDefinition routeDefinition) {
        return dynamicRouteService.updateRoute(routeDefinition);
    }

}